// HSS.Net.Dns.Request.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       Request.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;

namespace HSS.Net.Dns
{
	/// <summary>
	/// A Dns request object
	/// </summary>
	[System.CLSCompliant(false)]
	public class Request
	{
		/// <summary>
		/// The Request Header
		/// </summary>
		public Header header;

		private List<Question> questions;

		/// <summary>
		/// Constructor
		/// </summary>
		public Request()
		{
			header = new Header();
			header.OPCODE = OPCode.Query;
			header.QDCOUNT = 0;

			questions = new List<Question>();
		}
		/// <summary>
		/// Add a question to the request
		/// </summary>
		/// <param name="question"></param>
		public void AddQuestion(Question question)
		{
			questions.Add(question);
		}
		/// <summary>
		/// The Request data
		/// </summary>
		public byte[] Data
		{
			get
			{
				List<byte> data = new List<byte>();
				header.QDCOUNT = (ushort)questions.Count;
				data.AddRange(header.Data);
				foreach (Question q in questions)
					data.AddRange(q.Data);
				return data.ToArray();
			}
		}
	}
}